package com.me.bbs.controller;

import com.me.bbs.anno.RequireLogin;
import com.me.bbs.common.Resp;
import com.me.bbs.common.SessionUtils;
import com.me.bbs.entity.PostLike;
import com.me.bbs.service.IPostLikeService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lm
 * @since 2023-01-09
 */
@RestController
@RequestMapping("/postLike")
public class PostLikeController {
    @Resource
    IPostLikeService postLikeService;
    @PostMapping("/{postId}")
    @RequireLogin
    public Resp<?> addLike(@PathVariable Long postId) throws Exception {
        postLikeService.savePostLike(postId);
        return Resp.success();
    }

    @DeleteMapping("/{postId}")
    @RequireLogin
    public Resp<?> deleteLike(@PathVariable Long postId) throws Exception {
        postLikeService.delPostLike(postId);
        return Resp.success();

    }
}
